<?php

/**
 * 积分参数配置
 * @copyright (c) 2013, Alvin
 * 
 */
class SettingAction extends AdminAction {

    protected $site_config, $Config;

    public function _initialize() {
        parent::_initialize();
        $this->Config = D("Config");
        import('Form');
        $config       = $this->Config->select();
        foreach ($config as $key => $r) {
            $this->site_config[$r['varname']] = Input::forShow($r['value']);
        }
        $this->assign('Site', $this->site_config);
    }

    public function index() {
        if (IS_POST) {
            $this->dosite();
        } else {
            $this->display();
        }
    }

    //更新配置
    protected function dosite() {
        if (!$this->Config->autoCheckToken($_POST)) {
            $this->error("令牌验证失败！");
        }
        unset($_POST[C("TOKEN_NAME")]);
        foreach ($_POST as $key => $value) {
            $data["value"] = trim($value);
            $this->Config->where(array("varname" => $key))->save($data);
        }
        $this->success("更新成功！");
    }
    
    
    public function recharge(){
        if (IS_POST) {
            $this->dosite();
        } else {
            $this->display();
        }
    }

}

?>
